package com.epam.cdp.web;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.epam.cdp.ejb.stateless.jms.JMSQueueClient;
import com.epam.cdp.ejb.stateless.jms.MessageSender;

public class MessageDrivenExampleBackingBean {
	private final static Log log = LogFactory.getLog(MessageDrivenExampleBackingBean.class);
	
	private String messageText;
	
	@EJB
	private MessageSender<String> queueClient;

	public void sendMessage() {
		log.info("Sending message " + messageText);
		queueClient.sendMessage(messageText);
		messageText = "";
	}
	
	public String getMessageText() {
		return messageText;
	}

	public void setMessageText(String messageText) {
		this.messageText = messageText;
	}

	public MessageSender<String> getQueueClient() {
		return queueClient;
	}

	public void setQueueClient(JMSQueueClient queueClient) {
		this.queueClient = queueClient;
	}

	@PostConstruct
	public void postConstruct() {
		log.info("JMS Example Backing Bean Was Created");
	}
}
